package cn.fancy.sdk.login;

import android.content.Context;
import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import cn.fancy.sdk.common.utils.ResUtil;

public class ShowToastMsg {
	Context mContext;
	 ShowToastMsg() {
		Log.e("toast","new a ShowToastMsg Class");
	}

	public void show(Context context, String msg) {
		mContext =  context;
		LayoutInflater inflater = LayoutInflater.from(mContext);
		View toastRoot = inflater.inflate(
				ResUtil.getLayoutId(mContext, "fancy_toast_loginsuccess"), null);
		SpannableString spannableString = new SpannableString(msg);
		spannableString.setSpan(new ForegroundColorSpan(Color.BLACK),
				spannableString.length() - 8, spannableString.length(),
				Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		Toast toast = new Toast(mContext);
		toast.setView(toastRoot);
		TextView tv = (TextView) toastRoot.findViewById(ResUtil.getId(mContext,
				"TextViewInfo"));
		toast.setGravity(Gravity.TOP, 0, 10);
		tv.setText(spannableString);
		toast.show();
	}
}